//
//  GatherSingleCell.m
//  TryShopping
//
//  Created by panquanReabam.com on 16/10/19.
//  Copyright © 2016年 RuiBen. All rights reserved.
//

#import "GatherSingleCell.h"
#import "GetAddBuyGoodsView.h"
#import "GetAddBuyGoodsView1.h"
@interface GatherSingleCell()

@end
@implementation GatherSingleCell
{
    GetAddBuyGoodsView1*GoodView1;
    GetAddBuyGoodsView*GoodView;
    NSString*isSuit;
}
-(instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
    if (self = [super initWithStyle:style reuseIdentifier:reuseIdentifier]) {
        //        [self createView];
        //        [self setViewAutoLayout];
    }
    return self;
}
-(void)setGoodsInOrderListModel:(SelectedGoodNewHeaderDataModel *)GoodsInOrderListModel{
    

//    
            NSString *s1 =[NSString stringWithFormat:@"%@", GoodsInOrderListModel.itemName ];
            UIFont *font1 = [UIFont systemFontOfSize:14];
            CGSize size1 = CGSizeMake(ScreenWidth-125, 2000);
            CGSize labelsize12 = [s1 sizeWithFont:font1 constrainedToSize:size1 lineBreakMode:NSLineBreakByCharWrapping];
            
            
            _productNameLabel=[[UILabel alloc] initWithFrame:CGRectMake(109, 20, ScreenWidth-125, labelsize12.height)];
            [_productNameLabel setText:[NSString stringWithFormat:@"%@",  s1]];
            _productNameLabel.font=[UIFont systemFontOfSize:14];
            _productNameLabel.numberOfLines=0;
            _productNameLabel.textColor=[UIColor colorWithRed:51.0/255.0f green:51.0/255.0f  blue:51.0/255.0f  alpha:1.0];
            [self addSubview:_productNameLabel];
            
    

        
        _productImageView=[[UIImageView alloc] initWithFrame:CGRectMake(15, 20, 82, 82)];
        _productImageView.layer.borderColor=[[UIColor colorWithRed:239.0f/255.0f green:239.0f/255.0f blue:239.0f/255.0f alpha:1] CGColor];
        _productImageView.layer.borderWidth= 0.5f;
        [_productImageView setImageWithURL:[NSURL URLWithString:GoodsInOrderListModel.headImageFull] placeholderImage:[UIImage imageNamed:@"zhengfangxing"]];
        [self addSubview:_productImageView];
        
        
        
        if ([[Global getJudgeTheErrorStr:GoodsInOrderListModel.specName]isEqualToString:@""]||GoodsInOrderListModel.specName==NULL  ) {
            
        }else{
            _productSpecNameLabel=[[UILabel alloc] initWithFrame:CGRectMake(109, 55, 200, 15)];
            [_productSpecNameLabel setText:[NSString stringWithFormat:@"%@",GoodsInOrderListModel.specName ]];
            _productSpecNameLabel.font=[UIFont systemFontOfSize:12];
            _productSpecNameLabel.textColor=[UIColor colorWithRed:102.0/255.0f green:102.0/255.0f  blue:102.0/255.0f  alpha:1.0];
            [self addSubview:_productSpecNameLabel];
        }
        _productPriceLabel=[[UILabel alloc] initWithFrame:CGRectMake(109, 80, 200, 15)];
        [_productPriceLabel setText:[NSString stringWithFormat:@"¥ %0.02f",[GoodsInOrderListModel.dealPrice floatValue]]];
        _productPriceLabel.font=[UIFont systemFontOfSize:12];
        _productPriceLabel.textColor=[UIColor colorWithRed:102.0/255.0f green:102.0/255.0f  blue:102.0/255.0f  alpha:1.0];
        [self addSubview:_productPriceLabel];
        _productInvLabel=[[UILabel alloc] initWithFrame:CGRectMake(ScreenWidth-125, 55, 110, 15)];
        [_productInvLabel setText:[NSString stringWithFormat:@"库存 %d",[GoodsInOrderListModel.specInv intValue]]];
        _productInvLabel.font=[UIFont systemFontOfSize:12];
        _productInvLabel.textColor=[UIColor colorWithRed:109.0/255.0f green:102.0/255.0f  blue:102.0/255.0f  alpha:1.0];
        NSString *str=[NSString stringWithFormat:@"库存 %d",[GoodsInOrderListModel.specInv intValue]];
        NSMutableAttributedString *attriString = [[NSMutableAttributedString alloc] initWithString:str];
        [attriString addAttribute:NSForegroundColorAttributeName value:[UIColor colorWithRed:204.0/255.0 green:204.0/255.0 blue:204.0/255.0 alpha:1.0] range:NSMakeRange(0, 2)];
        
        _productInvLabel.attributedText=attriString;
        _productInvLabel.textAlignment=NSTextAlignmentRight;
        [self addSubview:_productInvLabel];
        
        _countParentView=[[UIView alloc] initWithFrame:CGRectMake(ScreenWidth-125, 72, 110, 30)];
        _countParentView.layer.borderWidth=1.0;
        _countParentView.layer.borderColor=[UIColor colorWithRed:240.0/255.0f green:240.0/255.0f blue:240.0/255.0f alpha:240.0/255.0f].CGColor;
        [self addSubview:_countParentView];
        _subtractCountBtn=[UIButton buttonWithType:UIButtonTypeCustom];
        [_subtractCountBtn setImage:[UIImage imageNamed:@"jian_hui.png"] forState:UIControlStateNormal];
        [_subtractCountBtn setFrame:CGRectMake(0, 0, 30,30)];
        [_subtractCountBtn addTarget:self action:@selector(subtractCountBtn:) forControlEvents:UIControlEventTouchUpInside];
        [_countParentView addSubview:_subtractCountBtn];
        
        _noSpecCountTextfield=[[UITextField alloc] initWithFrame:CGRectMake(30, 0, 50, 30)];
        _noSpecCountTextfield.text=[NSString stringWithFormat:@" %d",[GoodsInOrderListModel.shopCartQty intValue]];
        _noSpecCountTextfield.textColor=[UIColor colorWithRed:21.0/255.0 green:25.0/255.0 blue:32.0/255.0 alpha:1.0f];
        _noSpecCountTextfield.font=[UIFont systemFontOfSize:15];
        _noSpecCountTextfield.textAlignment=NSTextAlignmentCenter;
        [_noSpecCountTextfield setUserInteractionEnabled:NO];
        [_countParentView addSubview:_noSpecCountTextfield];
        _CountBtn=[UIButton buttonWithType:UIButtonTypeCustom];
        [_CountBtn setFrame:CGRectMake(0, 0, 50,30)];
        _CountBtn.center=_noSpecCountTextfield.center;
        [_CountBtn addTarget:self action:@selector(countBtn:) forControlEvents:UIControlEventTouchUpInside];
        [_countParentView addSubview:_CountBtn];
        _addCountBtn=[UIButton buttonWithType:UIButtonTypeCustom];
        [_addCountBtn setImage:[UIImage imageNamed:@"jia.png"] forState:UIControlStateNormal];
        [_addCountBtn setFrame:CGRectMake(80, 0, 30, 30)];
        [_addCountBtn addTarget:self action:@selector(addCountBtn:) forControlEvents:UIControlEventTouchUpInside];
        [_countParentView addSubview:_addCountBtn];
        
        self.lineLabel=[[UILabel alloc] initWithFrame:CGRectMake(10, 120-0.45, ScreenWidth-20, 0.45)];
        [self.lineLabel setBackgroundColor:qianhuiColor];
        [self addSubview:self.lineLabel];

    
}

-(void)subtractCountBtn:(UIButton *)sender
{
    [_mDelegate subtractCountBtn:[NSString stringWithFormat:@"%ld",sender.tag]:@"N"];

}
-(void)countBtn:(UIButton *)sender{
     [_mDelegate CountBtn:[NSString stringWithFormat:@"%ld",sender.tag]:@"N"];
    
    
}
-(void)addCountBtn:(UIButton *)sender{
    [_mDelegate addCountBtn:[NSString stringWithFormat:@"%ld",sender.tag]:@"N"];
}
- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];
    
    // Configure the view for the selected state
}

@end
